Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes: anticipating None values #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ioana-istrate-ciobanu
Copy link

Anticipating None values. Before, we were getting errors.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@ioana-istrate-ciobanu
Copy link
Author

If one CPT misses some or the entire required data, it shouldn't get populated with the data from the previously read CPT.

Test 1 - The first CPT contains data, but it is not read. Then, the second CPT does not get populated with data.

from geolib_plus.bro_xml_cpt import BroXmlCpt
import os
from pathlib import Path
out_dir = r""

cpt_xml1 = os.path.join(out_dir,"CPT000000038970"+".xml")
cpt_xml2 = os.path.join(out_dir,'CPT000000089280'+".xml")
# cpt_data1 = BroXmlCpt()
# cpt_data1.read(Path(cpt_xml1))

cpt_data2 = BroXmlCpt()
cpt_data2.read(Path(cpt_xml2))

# print(f"cpt_data1.depth {cpt_data1.depth is None}")
print(f"cpt_data2.depth {cpt_data2.depth is None}")

Output:

Backend TkAgg is interactive backend. Turning interactive mode on.
WARNING:root:CPT with id CPT000000089280 misses required data.
cpt_data2.depth True

Test 2 - The first CPT contains data and it is read. Because of that, the second CPT - which is supposed to be empty, gets populated with data.

from geolib_plus.bro_xml_cpt import BroXmlCpt
import os
from pathlib import Path
out_dir = r""

cpt_xml1 = os.path.join(out_dir,"CPT000000038970"+".xml")
cpt_xml2 = os.path.join(out_dir,'CPT000000089280'+".xml")
cpt_data1 = BroXmlCpt()
cpt_data1.read(Path(cpt_xml1))

cpt_data2 = BroXmlCpt()
cpt_data2.read(Path(cpt_xml2))

print(f"cpt_data1.depth {cpt_data1.depth is None}")
print(f"cpt_data2.depth {cpt_data2.depth is None}")

Output

Backend TkAgg is interactive backend. Turning interactive mode on.
WARNING:root:CPT with id CPT000000089280 misses required data.
cpt_data1.depth False
cpt_data2.depth False

image

@EleniSmyrniou
Copy link
Collaborator

Could you add the code you appended above as a unit test?

tests/test_none_values.py Outdated Show resolved Hide resolved
tests/test_none_values.py Outdated Show resolved Hide resolved
tests/test_none_values.py Show resolved Hide resolved
tests/test_none_values.py Show resolved Hide resolved
tests/test_none_values.py Outdated Show resolved Hide resolved
tests/test_none_values.py Outdated Show resolved Hide resolved
@EleniSmyrniou
Copy link
Collaborator

Thanks for your changes and writing a unit test!
I noticed you are using the unittest package.
In geolib-plus we are using pytest so I made some comments in the code on which lines need to be changed

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants